package com.gimi.cloud.bbp.client.service.moreInfo.impl;

import com.gimi.cloud.bbp.client.service.moreInfo.CreditcardEmailService;
import com.gimi.cloud.bbp.common.enums.ResponseCodeEnum;
import com.gimi.cloud.bbp.common.utils.Page;
import com.gimi.cloud.bbp.common.utils.reqhead.Response;
import com.gimi.cloud.bbp.dao.dao.moreInfo.FengchaoEmailDao;
import com.gimi.cloud.bbp.dao.dao.moreInfo.FengchaoPositionDao;
import com.gimi.cloud.bbp.dto.app.moreInfo.FengchaoEmailDTO;
import com.gimi.cloud.bbp.dto.app.moreInfo.FengchaoPositionDTO;
import com.gimi.cloud.bbp.entity.app.moreInfo.FengchaoEmailEntity;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @auther loongs
 * @date 2018/1/12  17:32
 */
@Service
public class CreditcardEmailServiceImpl implements CreditcardEmailService {

    private static final Logger log = LoggerFactory.getLogger(CreditcardEmailServiceImpl.class);

    private FengchaoEmailDao fengchaoEmailDao;
    private FengchaoPositionDao fengchaoPositionDao;
    @Autowired
    public CreditcardEmailServiceImpl(FengchaoEmailDao fengchaoEmailDao, FengchaoPositionDao fengchaoPositionDao) {
        this.fengchaoEmailDao = fengchaoEmailDao;
        this.fengchaoPositionDao = fengchaoPositionDao;
    }

    @Override
    public Response getFengchaoEmailList(FengchaoEmailDTO fengchaoEmailDTO) {
        Response response=new Response();
        Map<String,Object> data =new HashMap<>();
        List<FengchaoEmailEntity> fengchaoEmailEntityList=fengchaoEmailDao.selectAll();
        data.put("emailList",fengchaoEmailEntityList);
        response.setRes_data(data);
        response.setResponseCode(ResponseCodeEnum.SUCCESSED);
        return response;
    }

    @Override
    public Response getFengchaoPositionList(FengchaoPositionDTO fengchaoPositionDTO) {
        Response response=new Response();
        Map<String,Object> data =new HashMap<>();
        PageHelper.startPage(fengchaoPositionDTO.getCurrentPage(), fengchaoPositionDTO.getPageSize());
        List<FengchaoPositionDTO> result=fengchaoPositionDao.queryPageList(fengchaoPositionDTO);
        Page<FengchaoPositionDTO> page =new Page(new PageInfo<>(result));
        data.put("positionList",page);
        response.setRes_data(data);
        response.setResponseCode(ResponseCodeEnum.SUCCESSED);
        return response;
    }
}
